// sql语句
var sql = {
    // 用户
    user: {
        login: 'select * from admin where name = ? and password = ?',
        // 首页图书
        queryHello: 'select * from book',
        // 首页图书分类
        queryHellocate: 'select * from cate',
        // 首页图书详情
        queryHellolist: 'select * from book where id = ?',
        // 首页图书详情数据
        queryarticlelst: 'select chapter.namebook,chapter.id from book,chapter where book.id = ? and book.time = chapter.bookid order by chapter.id limit 1',
        // 首页图书详情数据下一章
        queryarticlexyz: 'select * from chapter where id = ? limit 1',
        //图书详情评论
        queryHellopl: 'select * from comment,login where bid = ? and nid = login.id',
        //添加用户
        loginadd: 'INSERT INTO login (id,name,password) VALUES (?,?,?)',
        //添加管理员
        adminadd: 'INSERT INTO admin (id,name,password) VALUES (?,?,?)',
        //更新管理员
        adminaddupdate: 'update admin set name = ? and password = ? where id = ?',
        //更新用户
        useraddupdate: 'update admin set name = ? and password = ? where id = ?',
        //更新分类
        cateaddupdate: 'update cate set title = ? where id = ?',
        //添加分类
        cateadd: 'INSERT INTO cate (id,title) VALUES (?,?)',
        //添加图书
        bookadd: 'INSERT INTO book (id,cid,name,auth,textarea,time) VALUES (?,?,?,?,?,?)',
        //添加图书章节
        bookaddadd: 'INSERT INTO chapter (id,namebook,bookid) VALUES (?,?,?)',
        //用户
        queryAdminUist: 'select * from login',
        // 管理员
        queryAdminList: 'select * from admin',
        // 管理员删除
        queryAdmindel: 'delete from admin where name = ?',
        //更新管理员数据
        queryAdminadminlst: 'select * from admin where id = ?',
        //更新用户数据
        queryuseruserlst: 'select * from login where id = ?',   
           //更新分类数据
        querycatecatelst: 'select * from cate where id = ?',  
        //图书
        queryAdminBooks: 'select * from book,cate where book.cid = cate.id',
        //图书章节列表
        queryAdminBookslst: 'select * from chapter where bookid = ?',
        //后台图书评论
        querycomment: 'select comment.id,login.name,book.name as bname,book.auth,comment.names,comment.time from comment,login,book where comment.bid = book.id and comment.nid = login.id',
        //后台图书评论删除
        querygetcommentdel: 'delete from comment where id = ?',
        //后台分类删除
        querygetcatedel: 'delete from cate where id = ?',
        //后台用户删除
        querygetuserdel: 'delete from login where id = ?',
        //后台管理员删除
        querygetadminsdel: 'delete from admin where id = ?',
        //分类
        getAdminCate:'select * from cate',

      
    },
    article: {
        query: 'select * from article',
        queryById: 'select * from article where discuss_id = ?',
        create: 'INSERT INTO article (title, content, keyword, type_id, type_name) VALUES (?,?,?,?,?)',
        delete: 'delete from article where discuss_id = ?',
        update: 'update article set title=?,content=?,keyword=? where discuss_id = ?',
        queryArticleType: 'select * from article_type',
        createArticleType: 'INSERT INTO article_type (typeId, typeName, createDate) VALUES (?,?,?)',
        queryArticleTypeById: 'select * from article_type where typeId = ?'
    },
    //图书
    books:{
        queryBooksList: 'select * from book',
    }
}
    
module.exports = sql;
